/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import com.click.app.Functions;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author ariel
 */
@Entity
@Table(name="payments_salaries")
public class PaymentsSalary implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Date datePay;
    private String typePay;
    private Double amount;
    private Salary salary;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_payments_salary", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "date_pay")
    @Temporal(value = javax.persistence.TemporalType.DATE)
    public Date getDatePay() {
        return datePay;
    }

    public void setDatePay(Date datePay) {
        this.datePay = datePay;
    }

    @Column(name = "type_pay")
    public String getTypePay() {
        return typePay;
    }

    public void setTypePay(String typePay) {
        this.typePay = typePay;
    }

    public Double getAmount() {
        return Functions.getDouble3Decimal(amount);
    }

    public void setAmount(Double amount) {
        this.amount = Functions.getDouble3Decimal(amount);
    }

    @JoinColumn(name = "id_salary", referencedColumnName = "id_salary")
    @ManyToOne(optional = false)
    public Salary getSalary() {
        return salary;
    }

    public void setSalary(Salary salary) {
        this.salary = salary;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PaymentsSalary)) {
            return false;
        }
        PaymentsSalary other = (PaymentsSalary) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.PaymentsSalary[id=" + id + "]";
    }

}
